package net.anzhuo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.common.enums.ResultEnum;
import net.anzhuo.common.utils.ExceptionUtil;
import net.anzhuo.dao.GsZhuzuoquanMapper;
import net.anzhuo.entity.GsZhuzuoquan;
import net.anzhuo.service.GsZhuzuoquanService;

@Service
public class GsZhuzuoquanServiceImpl implements GsZhuzuoquanService {

	@Autowired
	private GsZhuzuoquanMapper gsZhuzuoquanMapper;

	@Override
	public PaginationVO<GsZhuzuoquan> getListWithPage(GsZhuzuoquan gsZhuzuoquan) {
		PaginationVO<GsZhuzuoquan> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsZhuzuoquanMapper.getListWithPage(gsZhuzuoquan));
		paginationVO.setTotalCount(gsZhuzuoquanMapper.getCount(gsZhuzuoquan));
		paginationVO.setTotalPage((gsZhuzuoquanMapper.getCount(gsZhuzuoquan) + gsZhuzuoquan.getPageSize() -1)  / gsZhuzuoquan.getPageSize());
		paginationVO.setPageNo(gsZhuzuoquan.getPageNo());
		return paginationVO;
	}

	@Override
	public GsZhuzuoquan getById(Long id) {
		return gsZhuzuoquanMapper.getById(id);
	}

	@Override
	public List<GsZhuzuoquan> getList() {
		return gsZhuzuoquanMapper.getList();
	}

	@Override
	public List<GsZhuzuoquan> getList(GsZhuzuoquan gsZhuzuoquan) {
		return gsZhuzuoquanMapper.getListByQuery(gsZhuzuoquan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsZhuzuoquan gsZhuzuoquan) {
		gsZhuzuoquanMapper.update(gsZhuzuoquan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsZhuzuoquan gsZhuzuoquan) {
		gsZhuzuoquanMapper.save(gsZhuzuoquan);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsZhuzuoquan gsZhuzuoquan) {
		gsZhuzuoquanMapper.delete(gsZhuzuoquan);
	}

	@Override
	public List<GsZhuzuoquan> getByMd5(String md5) {
		return gsZhuzuoquanMapper.getByMd5(md5);
	}
}
